package br.ufrj.dcc.trabxml;

import java.io.IOException;
import java.net.UnknownHostException;

public class MySender {
    
    public static String send(String host, int port, String xml) throws UnknownHostException, IOException {
        MySenderReceiver rcv = new MySenderReceiver();
        Thread killer = MyConnector.getInstance().send(host,port,xml,rcv);
        try {
            killer.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return rcv.xml;
    }  
    
    public static void sendBack(String host, int port, String xml) throws UnknownHostException, IOException {
        MyConnector.getInstance().send(host,port,xml);
    }      

}

class MySenderReceiver implements XmlReceiver {
    
    public String xml = null;

    public void receive(String xml) {
        this.xml = xml;
    }
    
} 


